package gov.army.workshop.baseworkshop.model;

import java.util.Arrays;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Lob;
import javax.persistence.Table;

@Entity
@Table(name="NEWS")

public class News extends BaseObject {	
	private static final long serialVersionUID = -4754024941370668749L;
	private Long id;
	private String heading;
	private String newsDetail;
	private Boolean active=true;
	private byte[] image;
	

	@Id
    @GeneratedValue(strategy = GenerationType.AUTO)
	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	/**
	 * @return the heading
	 */
	@Column(name = "HEADING")
    
	public String getHeading() {
		return heading;
	}

	/**
	 * @return the newsDetail
	 */
	@Column(name = "DETAIL")
    
	public String getNewsDetail() {
		return newsDetail;
	}

	/**
	 * @return the image
	 */
	@Column(name = "IMAGE")
	@Lob
	public byte[] getImage() {
		return image;
	}

	/**
	 * @param heading the heading to set
	 */
	public void setHeading(String heading) {
		this.heading = heading;
	}

	/**
	 * @param newsDetail the newsDetail to set
	 */
	public void setNewsDetail(String newsDetail) {
		this.newsDetail = newsDetail;
	}

	/**
	 * @param image the image to set
	 */
	public void setImage(byte[] image) {
		this.image = image;
	}
	/**
	 * @return the active
	 */
	public Boolean getActive() {
		return active;
	}

	/**
	 * @param active the active to set
	 */
	public void setActive(Boolean active) {
		this.active = active;
	}


	/* (non-Javadoc)
	 * @see java.lang.Object#hashCode()
	 */
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((heading == null) ? 0 : heading.hashCode());
		result = prime * result + ((id == null) ? 0 : id.hashCode());
		result = prime * result + Arrays.hashCode(image);
		result = prime * result
				+ ((newsDetail == null) ? 0 : newsDetail.hashCode());
		return result;
	}

	/* (non-Javadoc)
	 * @see java.lang.Object#equals(java.lang.Object)
	 */
	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		News other = (News) obj;
		if (heading == null) {
			if (other.heading != null)
				return false;
		} else if (!heading.equals(other.heading))
			return false;
		if (id == null) {
			if (other.id != null)
				return false;
		} else if (!id.equals(other.id))
			return false;
		if (!Arrays.equals(image, other.image))
			return false;
		if (newsDetail == null) {
			if (other.newsDetail != null)
				return false;
		} else if (!newsDetail.equals(other.newsDetail))
			return false;
		return true;
	}

	/* (non-Javadoc)
	 * @see java.lang.Object#toString()
	 */
	@Override
	public String toString() {
		return "News [id=" + id + ", heading=" + heading + ", newsDetail="
				+ newsDetail + ", image=" + Arrays.toString(image) + "]";
	}

	

}
